﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.JHWorkflowTrans;
using Microhard.WarehouseInsp.Buz.DataAccess;
using Microhard.Permission.Interface;
using Microhard.Core;

namespace Microhard.WarehouseInsp.Buz.JHWorkflow
{
    public class SendAlertByJH
    {
        public static void SendAlert(Guid prjID, string content)
        {
            string usercodes = System.Configuration.ConfigurationManager.AppSettings["OutSupDetailAlertUserID"];
            var users = usercodes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            WarehouseInspEntities db = new WarehouseInspEntities();
            var prj = db.SupProjects.SingleOrDefault(s => s.ProjectID == prjID);
            IUser iuser = IoC.Resolve<IUser>();
            //数据专员
            var pm = iuser.GetModelByID(prj.PMID.Value);
            users.Add(pm.UserName);
            //巡检员
            var pm2 = iuser.GetModelByID(prj.ProtalEmpID.Value);
            users.Add(pm2.UserName);
            foreach (var u in users)
            {
                JHWorkflowTool.SendCallToUser(content, u);
            }
        }
    }
}
